<%--
  Created by IntelliJ IDEA.
  User: Wy
  Date: 2022/5/13
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        table{
            border: 1px solid orange;
            width: 1000px;
            margin: 10px auto;
            text-align: center;
            border-collapse: collapse;
        }
        tr{
            border: 1px solid orange;
            height: 50px;
            text-align: center;
        }
        td,th{
            border: 1px solid orange;
        }
        h2{
            text-align: center;
        }*



    </style>
</head>
<body>

<h2>图书列表</h2>

<a href="addBook.jsp">添加图书</a>
<a href="1.html">退出</a>
<br>
<p>欢迎【${uname}】</p>
  <table>
      <tr>
          <th>编号</th>
          <th>书名</th>
          <th>价格</th>
          <th>简介</th>
          <th>作者</th>
          <th>出版社</th>
          <th>删除操作</th>
          <th>修改操作</th>
      </tr>
<%--  展示域中的数据    --%>
      <c:forEach items="${bookList}" var="book">
          <tr>
              <td>${book.id}</td>
              <td>${book.name}</td>
              <td>${book.price}</td>
              <td>${book.description}</td>
              <td>${book.author}</td>
              <td>${book.publisher}</td>
              <td><a href="deletebook?bookId=${book.id}" onclick="return confirm('确定删除')">删除</a></td>
              <td><a href="toUpdate?bookIds=${book.id}" onclick="return confirm('确定修改')">修改</a></td>
          </tr>
      </c:forEach>
      <tr>
          <td colspan="8">
              <!--  pageContext.request.contextPath可以获取到 http://localhost:8080/bookList-->
              <a href="<c:url  value='/bookList?pageIndex=1'></c:url> ">首页</a>
              <!--如果当前在第一页, 不能点击上一页-->
              <c:if test="${page.pageIndex > 1}">
              <a href="<c:url value='/bookList?pageIndex=${page.pageIndex - 1}'></c:url> ">上一页</a>
              </c:if>
              <!--点击下一页, 需要判断, 当前页一定小于总页数-->
              <c:if test="${page.pageIndex<page.totalPages}">
                  <a href="<c:url value='/bookList?pageIndex=${page.pageIndex + 1}'></c:url> ">下一页</a>
              </c:if>
              <!--点击下一页, 判断如果当前页等于总页数, 不允许点击下一页-->
              <c:if test="${page.pageIndex==page.totalPages}">
                      <a>下一页</a>
              </c:if>
              <!--尾页 = 最后一页也就是总页数-->
              <a href="<c:url value='/bookList?pageIndex=${page.totalPages}'></c:url> ">尾页</a>
          </td>

      </tr>

  </table>

</body>
</html>
